<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    blog_month: "",
    nick_name: "",
    category_id: 0,
    property_id: 0,
    family_id: 0,
    plan_id: 0,
    bills_type: 0,
    amount: 0
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-row :gutter="30">
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="流水月份" prop="blog_month">
          <el-input
            v-model="newFormInline.blog_month"
            clearable
            placeholder="请输入流水月份"
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="家庭名称：" prop="family_id">
          <el-select
            v-model="newFormInline.family_id"
            placeholder="请选择家庭名称："
            clearable
          >
            <el-option label="支出" value="1" />
            <el-option label="收入" value="2" />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="金额：" prop="amount">
          <el-input
            v-model="newFormInline.amount"
            placeholder="请输金额："
            clearable
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="分类名称：" prop="category_id">
          <el-select
            v-model="newFormInline.category_id"
            placeholder="请选择分类名称："
            clearable
          >
            <el-option label="支出" value="1" />
            <el-option label="收入" value="2" />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="资产名称：" prop="property_id">
          <el-select
            v-model="newFormInline.property_id"
            placeholder="请选择资产名称："
            clearable
          >
            <el-option label="支出" value="1" />
            <el-option label="收入" value="2" />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="账单类型：" prop="bills_type">
          <el-select
            v-model="newFormInline.bills_type"
            placeholder="请选择账单类型："
            clearable
          >
            <el-option label="支出" value="1" />
            <el-option label="收入" value="2" />
          </el-select>
        </el-form-item>
      </re-col>
    </el-row>
  </el-form>
</template>
